package com.qyl.honghengshop.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.qyl.honghengshop.dao.BaseDao;
import com.qyl.honghengshop.dao.OrderItemDao;
import com.qyl.honghengshop.dto.OrderItem;
import com.qyl.honghengshop.dto.User;
import com.qyl.honghengshop.mapper.OrderItemMapper;


public class OrderItemDaoImpl extends BaseDao implements OrderItemDao {

	@Override
	public void saveOrderItem(OrderItem orderItem) {

		//获得session对象
		SqlSession sqlSession = this.getSqlSession();
		
		OrderItemMapper itemMapper = sqlSession.getMapper(OrderItemMapper.class);
		
		itemMapper.saveOrderItem(orderItem);
		
		sqlSession.commit();
		
		this.closeSqlSession();
		
	}

	@Override
	public List<OrderItem> getOrderItemList(User user) {

		//获得session对象
		SqlSession sqlSession = this.getSqlSession();
		
		OrderItemMapper itemMapper = sqlSession.getMapper(OrderItemMapper.class);
		
		List<OrderItem> orderItems = itemMapper.getOrderItemList(user);
		
		this.closeSqlSession();
		
		return orderItems;
	}

	@Override
	public List<OrderItem> showOrderItemByOid(Integer oid) {

		//获得session对象
		SqlSession sqlSession = this.getSqlSession();
		
		OrderItemMapper itemMapper = sqlSession.getMapper(OrderItemMapper.class);
		
		List<OrderItem> orderItems = itemMapper.showOrderItemByOid(oid);
		
		this.closeSqlSession();
		
		return orderItems;
	}

}
